package com.flyme.module.base.provider.service.impl;


import com.flyme.core.base.supper.service.impl.BaseServiceImpl;
import com.flyme.module.base.client.constants.BaseConstants;
import com.flyme.module.base.client.entity.SysDictData;
import com.flyme.module.base.provider.mapper.SysDictDataMapper;
import com.flyme.module.base.provider.service.SysDictDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 字典数据接口实现
 *
 * @author flyme
 */
@Slf4j
@Service
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements SysDictDataService {

    @Override
    public List<SysDictData> findByDictId(Long dictId) {
        return list(q().eq("dictId", dictId).eq("dicStatus", BaseConstants.ENABLED).orderByAsc("sortOrder"));
    }

    @Override
    public void deleteByDictId(Long dictId) {
        remove(q().eq("dictId", dictId));
    }

    /**
     * 根据上级id查询
     */
    public List<Map<String, Object>> selectByPar(Long id){
        List<Map<String, Object>> list = listMaps(q().select("dicDataTitle name,id code").eq("dictId", id).eq("dicStatus", 1).orderByAsc("sortOrder"));
        return list;
    }
}